<?php
/*
Plugin Name: Login Logout on Menu
Description: This plugin puts a login or logout menu on your WordPress Custom menus.
Original code found <a href="http://vanweerd.com/enhancing-your-wordpress-3-menus/#add_login">here</a>.
More explanation <a href="http://premium.wpmudev.org/blog/how-to-add-a-loginlogout-link-to-your-wordpress-menu/">here</a>.
*/
$columns_Arr[] = array($accoutingnumber=1,$insname=2,$companyname=3,$adjustercompany=4,$refetype=5,$referral_name=6,$refsource_name=7,$program_name=8);	
		
				$filename = "Cleanupsheet.csv";
				header("Content-type: application/octet-stream\n");
				header("Content-disposition: attachment; filename=\"$filename\"\n");		
				header("Content-transfer-encoding: binary\n");
							
				for($i=0; $i < count($columns_Arr); $i++){
					$data_arr = "";
					$header = "";
					foreach($columns_Arr[$i] as $key=>$value){					
						if($i == 0){
							if(is_array($value)){
								foreach($value as $field=>$val){
									$header .= '"'.trim($field).'",';
								}
							}							
						}
						if(is_array($value)){
							foreach($value as $field=>$val){
								$data_arr .= '"' . $val . '",';
							}
						}					
						$data_arr .=  '"'. $value  .'",';						
					}
					if($i==0){
						echo $header . 'JOB,INSURED NAME,INSURANCE COMPANY,INDEP.ADJUSTER COMPANY,REF.TYPE,REF.NAME,REF.SOURCE,PROGRAM'. "\n";

					}
					rtrim($data_arr,",");
					echo $data_arr . "\n";
				}
				exit;